<?php
include_once 'controller/default.php';
include_once 'connection/connection_database.php';

class lienket {

    function Insert($lienket) {
        $link = "http://".$lienket["lienket_link"];
        $sql = "INSERT INTO lienket(lienket_name, lienket_link)"; 
        $sql .= "VALUES('{$lienket["lienket_name"]}', '{$link}')";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }

    function Delete($lienket) {
        $sql = "DELETE FROM lienket WHERE lienket_id='{$lienket["id"]}'";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }

    function Update($lienket) {
        $link = "http://".$lienket["lienket_link"];
        $sql = "UPDATE lienket SET lienket_name='{$lienket["lienket_name"]}', lienket_link='{$link}' WHERE lienket_id='{$lienket["id"]}'";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }

    function FillAll() {
        $sql = "SELECT * FROM lienket";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }

    function FillOne($lienket) {
        $sql = "SELECT * FROM lienket WHERE lienket_id='{$lienket["id"]}'";
        $result = mysql_query($sql) or die(mysql_error());
        return mysql_fetch_array($result);
    }
}

?>
